<!--指派销售机会页----------仅销售主管可看-->
<template>
  <div id="SalesChanceAssignTo">
    <div class="breadcrumbs" style="margin: 0px;padding-top: 20px;">
      <ul>
        <li class="home"><a href="index.html" title="Go to Home Page"><strong style="font-size: 18px;">营销管理</strong></a>
          <span>/</span>
        </li>
        <li><strong>销售机会管理</strong><span>/</span></li>
        <li><strong>指派销售机会</strong></li>
      </ul>
    </div>
    <article class="col-main">
      <div class="my-account block block-account" style="padding-left: 20px;">

        <div class="page-title" style="border-bottom: #F1F3F6 1px solid;">
          <h2>指派销售机会</h2>
          <hr>
        </div>

        <div style="margin: 0px 20px 40px 20px">
          <el-radio-group v-model="size">
            <el-radio label="">默认</el-radio>
            <el-radio label="medium">中等</el-radio>
            <el-radio label="small">小型</el-radio>
            <el-radio label="mini">超小</el-radio>
          </el-radio-group>
          <el-descriptions style="margin-top: 20px" class="margin-top" title="" :column="3" :size="size" border>
            <el-descriptions-item>
              <template slot="label">
                销售机会编号
              </template>
              {{salesChance.saleId}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                机会来源
              </template>
              {{salesChance.saleSource}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                客户名称
              </template>
              {{ salesChance.customerName }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                成功几率(%)
              </template>
              {{ salesChance.successProbability }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                销售机会概要
              </template>
              {{ salesChance.saleOutline }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
              </template>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                联系人
              </template>
              {{ salesChance.contactsName }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                联系人电话
              </template>
              {{ salesChance.contactsTel1 }}
            </el-descriptions-item>

            <el-descriptions-item>
              <template slot="label">
                机会描述
              </template>
              {{ salesChance.saleDescribe }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                创建人
              </template>
              {{salesChance.saleCreaterName}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                创建时间
              </template>
              {{salesChance.saleDate}}
            </el-descriptions-item>
          </el-descriptions>

        </div>

        <form action="">
          <div style="border-bottom: 2px #D9D9D9 solid;margin-right: 20px;margin-bottom: 20px"></div>

          <div class="form-group">
            <strong style="font-weight: 1000;font-size: 20px">指派给</strong>
            &nbsp;<span style="color: red;font-size: 15px">*</span>
            <div style="padding-left: 20px;">
              <select v-model="saleAssign.staffId" style="width: 400px;" class="form-control">
                <option class="text-center" value="">--请选择--</option>
                <option v-for="item in accountManagers" class="text-center" :value="item.staffId">{{item.staffName}}</option>
              </select>
            </div>
          </div>

          <div class="form-group">
            <strong style="font-weight: 1000;font-size: 20px">指派时间</strong>
            &nbsp;<span style="color: red;font-size: 15px">*</span>
            <div style="padding-left: 20px;">
              <input v-model="saleAssignDate" readonly="readonly" type="date" class="form-control" style="width: 400px;"/>
            </div>
          </div>

          <div class="text-center" style="margin-top: 40px;padding-bottom: 30px">
            <button v-on:click="assignAccountManager" class="btn btn-primary">确认指派</button>
            <router-link to="/MemuBar/SalesChanceList" class="btn btn-default">返回</router-link>
          </div>
        </form>

      </div>
    </article>
  </div>
</template>

<script>
export default {
  name: "AssignSalesChance",
  data(){
    return{
      salesChance: {},
      accountManagers:[

      ],
      saleAssign:{
        saleId:'',
        staffId:'',
      },
      size: '',
      saleAssignDate:'',
    }
  },
  methods:{
    getAllAccountManagers() {
      this.$axios.get('/staff/loadAllAccountManager').then(
        res=>{
          this.accountManagers = res.data.data;
        }
      )
    },
    getSaleChance(){
      this.saleAssignDate = new Date().getFullYear()+'-0'+(new Date().getMonth()+1)+'-'+new Date().getDate();
      console.log(this.saleAssignDate)
      this.$axios.get('/sale/loadSale',{
        params:{
          saleId:this.$route.query.saleId
        }
      }).then(
        res=>{
          this.salesChance = res.data.data;
          this.saleAssign.staffId = res.data.data.staffId
          // console.log(this.salesChance)
        }
      )
    },
    assignAccountManager(){
      this.saleAssign.saleId = this.$route.query.saleId
      this.$axios.put('/sale/assignAccountManager',this.saleAssign).then(
        res=>{
          this.$message({
            showClose: true,
            message: res.data.message,
            type: 'success'
          });
          this.$router.push("/MemuBar/SalesChanceList");
        }
      )
    }
  },
  created() {
    this.getAllAccountManagers()
    this.getSaleChance()
  }
}
</script>

<style scoped>
</style>
